class_name MapNode
extends RefCounted

enum NodeType {
	COMBAT,      # 普通战斗
	ELITE,       # 精英战斗
	BOSS,        # Boss战斗
	REST,        # 休息（汉府）
	SHOP,        # 商店（吾悦广场）
	EVENT,       # 随机事件
	TREASURE,    # 宝箱
	REMOVE_CARD, # 删牌事件
	UPGRADE_CARD,# 升级卡牌
	HEAL_EVENT,  # 治疗事件
	RANDOM_CARD  # 随机卡牌
}

var id: String
var node_type: NodeType
var floor_number: int
var x_position: int
var y_position: int
var is_accessible: bool = false
var is_visited: bool = false
var is_current: bool = false
var next_floor_connections: Array[MapNode] = []  # 连接到下一层的节点

# 节点内容
var event_data: Dictionary = {}
var rewards: Array = []

func _init(node_id: String, type: NodeType, floor_num: int, x: int, y: int):
	id = node_id
	node_type = type
	floor_number = floor_num
	x_position = x
	y_position = y

func get_node_name() -> String:
	match node_type:
		NodeType.COMBAT:
			return "普通战斗"
		NodeType.ELITE:
			return "精英战斗"
		NodeType.BOSS:
			return "Boss战斗"
		NodeType.REST:
			return "汉府"
		NodeType.SHOP:
			return "吾悦广场"
		NodeType.EVENT:
			return "随机事件"
		NodeType.TREASURE:
			return "宝箱"
		NodeType.REMOVE_CARD:
			return "删牌事件"
		NodeType.UPGRADE_CARD:
			return "升级卡牌"
		NodeType.HEAL_EVENT:
			return "治疗事件"
		NodeType.RANDOM_CARD:
			return "随机卡牌"
		_:
			return "未知"

func get_node_description() -> String:
	match node_type:
		NodeType.COMBAT:
			return "与考试怪物战斗"
		NodeType.ELITE:
			return "与强大的精英考试战斗"
		NodeType.BOSS:
			return "与最终Boss战斗"
		NodeType.REST:
			return "休息恢复生命值和能量"
		NodeType.SHOP:
			return "购买卡牌、遗物和药水"
		NodeType.EVENT:
			return "遇到随机事件"
		NodeType.TREASURE:
			return "获得遗物或药水"
		NodeType.REMOVE_CARD:
			return "删除一张卡牌"
		NodeType.UPGRADE_CARD:
			return "升级一张卡牌"
		NodeType.HEAL_EVENT:
			return "恢复生命值"
		NodeType.RANDOM_CARD:
			return "获得随机卡牌"
		_:
			return ""

func can_enter() -> bool:
	return is_accessible and not is_visited

func enter_node():
	is_visited = true
	is_current = true
